package com.cn.kabalifeuser.ui.my.activity;

import com.cn.kabalifeuser.api.Api;
import com.cn.kabalifeuser.base.BasePresenter;
import com.cn.kabalifeuser.callback.CacheCallBack;
import com.cn.kabalifeuser.config.Constants;
import com.cn.kabalifeuser.config.LoginHelper;
import com.cn.kabalifeuser.ui.my.bean.HelpDetailsBean;
import com.cn.kabalifeuser.ui.my.bean.IntegralRuleBean;
import com.cn.kabalifeuser.utils.LoggerUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;

/**
 * Created by 晓林 on 2020/9/10.
 * function:
 */
public class IntegralRulePresenter extends BasePresenter<IntegralRuleView> {

    public void onIntegralRuleData() {
        OkGo.<IntegralRuleBean>get(Api.API_USER_INTEGRALRULE)
                .headers("token", LoginHelper.getLonginData().getResult())
                .execute(new CacheCallBack<IntegralRuleBean>() {
                    @Override
                    public void onSuccess(Response<IntegralRuleBean> response) {
                        super.onSuccess(response);
                        LoggerUtils.e("帮助：" + response.body());
                        if (isViewAttached())
                            if (response.body().getCode() == Constants.HTTP_SUCCESS)
                                getView().onIntegralRuleSuccess(response.body());
                            else if (response.body().getCode() == Constants.HTTP_AGAIN_LOGIN)
                                getView().onReLoggedIn(response.body().getMsg());
                            else
                                getView().onError(response.body().getMsg());
                    }
                });
    }
}
